import React from 'react';
window.wm = new WeakMap()
export default () => {
    const dom = React.useRef<HTMLDivElement>(null)
    React.useEffect(() => {
        if (!dom.current) return
        window.wm.set(dom.current, 'why')
    }, [])
    const output = () => {
        console.log(window.wm)
    }
    const remove = () => {
        dom.current?.remove()
    }
    return (
        <div>
            <div ref={dom} id="weakMap" style={{ height: 10, background: 'red' }}></div>
            <button onClick={output}>输出信息</button>
            <button onClick={remove}>移除dom</button>
        </div>
    )
}